Lecture 2 - MIPS
Thursday, May 08, 2014
1:55 PM
|
||||||||||||||||||||||
|
Recall: 32 “general-purpose” registers, each holds 32 bits Eg: Add the contents of registers $s + $t, store the result in registry $d 2^5 = 32, 5 bits to store a registry #
15 bits to encode 3 registers leaves 17 bits to encode operation
RAM
Communicating with RAM – two commands
Q: How does the computer know which words contain instructions and which contain data? A: It doesn’t – special register called PC (program counter) holds the address of the next instruction to run
By convention, we guarantee that some address (say, 0) contains code, initialize PC to 0. Computer runs the fetch-execute cycle:
Q: How does a program get executed? A: Program called loader puts the program in memory and sets the PC to the address of the first instruction in the program
Q: What happens when a program ends? A: Need to return control to the loader to set PC to the address of the next instruction in the loader
Example 1: Add the values in registers 4 & 7, store the result in $3, then return. MIPS machine code:
Add:
Jump:
Example 2: Add 42 and 53, store sum in $3, then return
Assembly Language
Example 2 Revisited:
|
|||||||||||||||||||||
|
. |
|||||||||||||||||||||
|
Created with Microsoft OneNote 2010
One place for all your notes and information